<?php
namespace statistics\utils;
use statistics\utils\HTTPParameterReader;

class ScrollPosHandler {
	private $paramReader;
	public function __construct() {
		$this->paramReader = new HTTPParameterReader();
		$this->paramReader->setDataType('numeric');
		$this->paramReader->setDefaultValue(0);
	}
	public function readScrollPos() {
		return $this->paramReader->readGETParameter('scroll_pos');
	}
	public function addScrollPosToURL($url){	
		return $url.'&scroll_pos='.$this->readScrollPos();
	}
	public function removeScrollPosFromURL($currentURL){
		$pattern = '/&scroll_pos=\d*/';
		$replacement = '';
		$subject = $currentURL;
		return preg_replace($pattern,$replacement,$subject);
	}
}
?>